<?
include('./header.inc');
include('./database.inc');
include('./pagehead.inc');

$query = "SELECT * FROM users ORDER BY username ASC";
$result = mysql_query($query);


?>
<table>
	<tr class="headerrow"><th>Username</th><th>Edit</th><th>Delete</th></tr>
	<?
	$counter = 0;
	while($row = mysql_fetch_array($result)){
	?>
	<tr class="<? echo (($counter % 2) == 0 ? "even" : "odd" );?>">
	<td><? echo $row['username'];?></td>
	<td class="edit"><?
	if ($_SESSION['superuser'] == "true" || $_SESSION['uid'] == $row['user_id']){
	?>
	<a href="./edituser.php?uid=<? echo $row['user_id'];?>">edit</a>
	<?}?>
	</td>
	<td class="delete">
	<?
	if ($_SESSION['superuser'] == "true" && $_SESSION['uid'] != $row['user_id']){
	?>
	<a onclick="return confirm('Are you sure you want to delete this user?')" href="./deleteuser.php?uid=<? echo $row['user_id'];?>">delete</a>
	<?}?>
	</td>
	</tr>
	<?
	$counter++;
	}?>
</table>
<?
include('./pagefoot.inc');
?>